0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 12 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 274 ms)
↳10 BOUNDS(1, n^2)
minus(x, y) → cond(ge(x, s(y)), x, y)
cond(false, x, y) → 0
cond(true, x, y) → s(minus(x, s(y)))
ge(u, 0) → true
ge(0, s(v)) → false
ge(s(u), s(v)) → ge(u, v)
minus(x, y) → cond(ge(x, s(y)), x, y) [1]
cond(false, x, y) → 0 [1]
cond(true, x, y) → s(minus(x, s(y))) [1]
ge(u, 0) → true [1]
ge(0, s(v)) → false [1]
ge(s(u), s(v)) → ge(u, v) [1]
minus(x, y) → cond(ge(x, s(y)), x, y) [1]
cond(false, x, y) → 0 [1]
cond(true, x, y) → s(minus(x, s(y))) [1]
ge(u, 0) → true [1]
ge(0, s(v)) → false [1]
ge(s(u), s(v)) → ge(u, v) [1]
minus :: s:0 → s:0 → s:0 cond :: false:true → s:0 → s:0 → s:0 ge :: s:0 → s:0 → false:true s :: s:0 → s:0 false :: false:true 0 :: s:0 true :: false:true |
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
false => 0
0 => 0
true => 1
cond(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
cond(z, z', z'') -{ 1 }→ 1 + minus(x, 1 + y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
ge(z, z') -{ 1 }→ ge(u, v) :|: v >= 0, z' = 1 + v, z = 1 + u, u >= 0
ge(z, z') -{ 1 }→ 1 :|: z = u, z' = 0, u >= 0
ge(z, z') -{ 1 }→ 0 :|: v >= 0, z' = 1 + v, z = 0
minus(z, z') -{ 1 }→ cond(ge(x, 1 + y), x, y) :|: x >= 0, y >= 0, z = x, z' = y
eq(start(V, V1, V4),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[cond(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[ge(V, V1, Out)],[V >= 0,V1 >= 0]). eq(minus(V, V1, Out),1,[ge(V2, 1 + V3, Ret0),cond(Ret0, V2, V3, Ret)],[Out = Ret,V2 >= 0,V3 >= 0,V = V2,V1 = V3]). eq(cond(V, V1, V4, Out),1,[],[Out = 0,V1 = V5,V4 = V6,V5 >= 0,V6 >= 0,V = 0]). eq(cond(V, V1, V4, Out),1,[minus(V7, 1 + V8, Ret1)],[Out = 1 + Ret1,V1 = V7,V4 = V8,V = 1,V7 >= 0,V8 >= 0]). eq(ge(V, V1, Out),1,[],[Out = 1,V = V9,V1 = 0,V9 >= 0]). eq(ge(V, V1, Out),1,[],[Out = 0,V10 >= 0,V1 = 1 + V10,V = 0]). eq(ge(V, V1, Out),1,[ge(V11, V12, Ret2)],[Out = Ret2,V12 >= 0,V1 = 1 + V12,V = 1 + V11,V11 >= 0]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(cond(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(ge(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [ge/3]
1. recursive : [cond/4,minus/3]
2. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into ge/3
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations ge/3
* CE 10 is refined into CE [11]
* CE 8 is refined into CE [12]
* CE 9 is refined into CE [13]
### Cost equations --> "Loop" of ge/3
* CEs [12] --> Loop 8
* CEs [13] --> Loop 9
* CEs [11] --> Loop 10
### Ranking functions of CR ge(V,V1,Out)
* RF of phase [10]: [V,V1]
#### Partial ranking functions of CR ge(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V
V1
### Specialization of cost equations minus/3
* CE 7 is refined into CE [14,15]
* CE 6 is refined into CE [16]
### Cost equations --> "Loop" of minus/3
* CEs [16] --> Loop 11
* CEs [15] --> Loop 12
* CEs [14] --> Loop 13
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [11]: [V-V1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V-V1
### Specialization of cost equations start/3
* CE 2 is refined into CE [17,18,19]
* CE 3 is refined into CE [20]
* CE 4 is refined into CE [21,22,23]
* CE 5 is refined into CE [24,25,26,27]
### Cost equations --> "Loop" of start/3
* CEs [27] --> Loop 14
* CEs [23] --> Loop 15
* CEs [19] --> Loop 16
* CEs [18,22,26] --> Loop 17
* CEs [17,25] --> Loop 18
* CEs [20,21,24] --> Loop 19
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of ge(V,V1,Out):
* Chain [[10],9]: 1*it(10)+1
Such that:it(10) =< V
with precondition: [Out=0,V>=1,V1>=V+1]
* Chain [[10],8]: 1*it(10)+1
Such that:it(10) =< V1
with precondition: [Out=1,V1>=1,V>=V1]
* Chain [9]: 1
with precondition: [V=0,Out=0,V1>=1]
* Chain [8]: 1
with precondition: [V1=0,Out=1,V>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[11],12]: 3*it(11)+1*s(1)+1*s(4)+3
Such that:it(11) =< Out
aux(2) =< V1+Out
s(1) =< aux(2)
s(4) =< it(11)*aux(2)
with precondition: [V=Out+V1,V1>=0,V>=V1+1]
* Chain [13]: 3
with precondition: [V=0,Out=0,V1>=0]
* Chain [12]: 1*s(1)+3
Such that:s(1) =< V
with precondition: [Out=0,V>=1,V1>=V]
#### Cost of chains of start(V,V1,V4):
* Chain [19]: 3
with precondition: [V=0,V1>=0]
* Chain [18]: 4
with precondition: [V1=0,V>=0]
* Chain [17]: 1*s(5)+2*s(6)+4
Such that:s(5) =< V1
aux(3) =< V
s(6) =< aux(3)
with precondition: [V>=1,V1>=V]
* Chain [16]: 3*s(8)+1*s(10)+1*s(11)+4
Such that:s(9) =< V1
s(8) =< V1-V4
s(10) =< s(9)
s(11) =< s(8)*s(9)
with precondition: [V=1,V4>=0,V1>=V4+2]
* Chain [15]: 3*s(12)+1*s(14)+1*s(15)+3
Such that:s(13) =< V
s(12) =< V-V1
s(14) =< s(13)
s(15) =< s(12)*s(13)
with precondition: [V1>=0,V>=V1+1]
* Chain [14]: 1*s(16)+1
Such that:s(16) =< V1
with precondition: [V1>=1,V>=V1]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [19] with precondition: [V=0,V1>=0]
- Upper bound: 3
- Complexity: constant
* Chain [18] with precondition: [V1=0,V>=0]
- Upper bound: 4
- Complexity: constant
* Chain [17] with precondition: [V>=1,V1>=V]
- Upper bound: 2*V+V1+4
- Complexity: n
* Chain [16] with precondition: [V=1,V4>=0,V1>=V4+2]
- Upper bound: 3*V1-3*V4+ (V1+4+ (V1-V4)*V1)
- Complexity: n^2
* Chain [15] with precondition: [V1>=0,V>=V1+1]
- Upper bound: 3*V-3*V1+ (V+3+ (V-V1)*V)
- Complexity: n^2
* Chain [14] with precondition: [V1>=1,V>=V1]
- Upper bound: V1+1
- Complexity: n
### Maximum cost of start(V,V1,V4): max([max([1,nat(V-V1)*V+V+nat(V-V1)*3])+2,max([2*V+3,nat(V1-V4)*V1+3+nat(V1-V4)*3])+V1])+1
Asymptotic class: n^2
* Total analysis performed in 162 ms.